package uy.com.dino.samefile.util;

import java.io.File;
import java.io.FileFilter;
import java.util.List;

public class FileFilterListImpl implements FileFilter {

    private List<String> extensions;

    public void setExtensions(List<String> extension) {
        this.extensions = extension;
    }

    public boolean accept(File file) {
        boolean ret = file.isDirectory();
        if (!ret) {
            String name = file.getName();
            for (String extension : this.extensions) {
                ret = name.endsWith(extension);
                if (ret) {
                    break;
                }
            }
        }
        return ret;
    }
}
